function TaskAction() {
}
TaskAction.NONE = 0;
TaskAction.TAKE_PHOTO = 1;
TaskAction.INPUT_TEXT = 2;
TaskAction.INPUT_NUMBER = 3;
TaskAction.SELECT_SINGLE = 4;
TaskAction.SELECT_MULTIPLE = 5;
TaskAction.INPUT_MULTIPLE_SCORE=6;

TaskAction.FINISH = 9;

function PlanStatus() {
}
PlanStatus.NEW = "new";
PlanStatus.CONFIRM = "confirm";
PlanStatus.DENY = "deny";

function Task(obj) {
    if (obj) {
        this.id = obj.id;
        this.version = obj.version;
        this.actionId = obj.actionId;
        this.actionName = obj.actionName;
        this.dataTypeId = obj.dataTypeId;
        this.dataTypeName = obj.dataTypeName;
        this.taskItems = obj.taskItems;
    } else {
        this.id = null;
        this.version = 0;
        this.actionId = 0;
        this.actionName = '';
        this.dataTypeId = 0;
        this.dataTypeName = '';
        this.taskItems = [];
    }
}

Task.prototype.createItem = function(itemName) {
    var taskItem = new TaskItem();
    taskItem.name = itemName;
    this.taskItems.push(taskItem);
    return taskItem;
}

function TaskItem(obj) {
    if (obj) {
        this.id = obj.id;
        this.version = obj.version;
        this.name = obj.name;
        this.extra1=obj.extra1;
        this.extra2=obj.extra2;
        this.extra3=obj.extra3;
    } else {
        this.id = null;
        this.version = null;
        this.name = '';
        this.extra1='';
        this.extra2='';
        this.extra3='';
    }
}

function Step(obj) {
    if (obj) {
        this.id = obj.id;
        this.version = obj.version;
        this.task = new Task(obj.task);
        this.name = obj.name;
        this.fixed = obj.fixed;
        this.optional = obj.optional;
        this.stepsOrder = obj.stepsOrder;
        this.stepItems = [];
        this.checkBox=obj.checkBox;
        for (var i = 0; i < obj.stepItems.length; i++) {
            var stepItem = obj.stepItems[i];
            this.stepItems.push(new StepItem(stepItem));
        }
    } else {
        this.id = null;
        this.version = null;
        this.task = null;
        this.name = null;
        this.fixed = 0;
        this.optional = 0;
        this.stepsOrder = 0;
        this.stepItems = [];
        this.checkBox=0;
    }
}

Step.prototype.createStepItems = function() {
    this.stepItems = [];
    for (var i = 0; i < this.task.taskItems.length; i++) {
        var taskItem = this.task.taskItems[i];
        var stepItem = new StepItem();
        stepItem.taskItem = taskItem;
        this.stepItems.push(stepItem);
    }
}

function StepItem(obj) {
    if (obj) {
        this.id = obj.id;
        this.version = obj.version;
        this.taskItem = obj.taskItem;
        this.steps = [];
        for (var i = 0; i < obj.steps.length; i++) {
            var step = obj.steps[i];
            this.steps.push(new Step(step));
        }
    } else {
        this.id = null;
        this.version = null;
        this.taskItem = null;
        this.steps = [];
    }
}

StepItem.prototype.createStep = function(task, stepName) {
    var step = new Step();
    step.task = task;
    step.name = stepName;
    step.createStepItems();
    this.steps.push(step);
    return step;
}

function Job(obj) {
    if (obj) {
        this.id = obj.id;
        this.version = obj.version;
        this.name = obj.name;
        this.steps = [];
        for (var i = 0; i < obj.steps.length; i++) {
            var step = obj.steps[i];
            this.steps.push(new Step(step));
        }
    } else {
        this.id = null;
        this.version = null;
        this.name = '';
        this.steps = [];
    }
}

Job.prototype.createStep = function(task, name, fixed) {
    var step = new Step();
    step.task = task;
    step.name = name;
    step.fixed = fixed ? 1 : 0;
    step.createStepItems();
    this.steps.push(step);
    return step;
}

function PlanJob(obj) {
    if (obj) {
        this.id = obj.id;
        this.version = obj.version;
        this.storeCode = obj.storeCode;
        this.storeName = obj.storeName;
        this.storeAddress = obj.storeAddress;
        this.job = new Job(obj.job);
        this.jobId = obj.jobId;
        this.startTime = obj.startTime;
        this.endTime = obj.endTime;
        this.cooperateUser=obj.cooperateUser;
    } else {
        this.id = null;
        this.version = null;
        this.storeCode = null;
        this.storeName = null;
        this.storeAddress = null;
        this.job = null;
        this.jobId = null;
        this.startTime = null;
        this.endTime = null;
        this.cooperateUser=null;
    }
}

function PlanProject(obj) {
    if (obj) {
        this.id = obj.id;
        this.version = obj.version;
        //this.plan = new Plan(obj.plan);
        this.projectCode = obj.projectCode;
        this.projectName = obj.projectName;
        this.planJobs = [];
        for (var i = 0; i < obj.planJobs.length; i++) {
            var planJob = obj.planJobs[i];
            this.planJobs.push(new PlanJob(planJob));
        }
    } else {
        this.id = null;
        this.version = null;
        //this.plan = null;
        this.projectCode = null;
        this.projectName = null;
        this.planJobs = [];
    }
}

function Plan(obj) {
    if (obj) {
        this.id = obj.id;
        this.version = obj.version;
        this.name=obj.name;
        this.userLoginName = obj.userLoginName;
        this.planDate = obj.planDate;
        this.planProjects = [];
        this.status = obj.status.toString();
        for (var i = 0; i < obj.planProjects.length; i++) {
            var planProject = obj.planProjects[i];
            this.planProjects.push(new PlanProject( planProject));
        }
    } else {
        this.id = null;
        this.version = null;
        this.name=null;
        this.userLoginName = null;
        this.planDate = null;
        this.planProjects = [];
        this.status = PlanStatus.NEW;
    }
}
